// pages/mine/mine.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    status: 'not-login',
    userInfo: null,
    imgDomain: app.data.imgDomain
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({ userInfo: app.globalData.userInfo })
    if (this.data.userInfo && this.data.userInfo.uuid) {
      this.setData({status: 'login'})
    } else {
      this.setData({status: 'not-login'})
    }
  },
  scan: function () {
    wx.scanCode({
      success: (res) => {
        console.log(res)
      }
    })
  },
  login: function () {
    wx.showLoading({
      title: '登录中...',
    })
    app.login(res => {
      this.setData({ userInfo: res })
      this.setData({ status: 'login' })
    })
  },
  jump: function (event) {
    if (!event.currentTarget.dataset.jumpUrl) {
      return false;
    }
    wx.navigateTo({
      url: event.currentTarget.dataset.jumpUrl
    })
  }
})